#include <stdio.h>
#include <string.h>
#include <stdlib.h>


/*
 *	2013/4/14 16:49 qin
 */
/*
typedef struct a_t;
 
typedef struct b_t;
 
a_t a;
 
b_t b;
 
b = (a_t)a;
 
上面这中方法是错误的。
 
 
 
可以采用指针的方法实现：
 
a_t a;
 
b_t *pb;
 
pb = (a_t *)&a;
 
这样就把pb指针指向了a结构体中的内容，且可以通过pb->来引用其中元素

*/


typedef struct _astruct
{
	int a;
	unsigned char b;
}astruct;

typedef struct _bstruct
{
	unsigned char a;
	int b;
	unsigned char c;
}bstruct;

int main()
{
	astruct as;
	astruct * pas;

	bstruct bs;
	bstruct * pbs;


	as.a = 250;
	as.b = 'x';

	bs.a = 'i';
	bs.b = 255;
	bs.c = 'o';

	// bs = (bs)as;	error.

	pbs = (bstruct *)&as;
	#if 1
	printf("%d = %c\n", pbs->a, pbs->b);
	#else
	printf("%c = %d\n", pbs->a, pbs->b);
	#endif
	//printf("%c\n", pbs->c);

	pas = (astruct *)&bs;
	#if 1
	printf("%c = %d \n", pas->a, pas->b);
	#else
	printf("%d = %c \n", pas->a, pas->b);
	#endif

	return 0;
}



